package com.xh.bussiness.tms.controller;

import com.xh.bussiness.tms.model.Curriculum;
import com.xh.bussiness.tms.service.ICurriculumService;
import com.xh.core.bean.AjaxResult;
import com.xh.core.constant.AjaxResultConstant;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/curriculum")
public class CurriculumController {

    @Autowired
    private ICurriculumService curriculumService;

    @ApiOperation(value = "新增班级课次或者更新班级课次",notes = "新增班级课次或者更新班级课次")
    @PostMapping("/saveOrUpdate")
    public AjaxResult saveOrUpdate(@Validated Curriculum bean){
        if(bean.getId()==null){
            curriculumService.insert(bean);
        }else{
            curriculumService.update(bean);
        }
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS,"",bean);
    }
}
